<template>
  <div>
      <myhead></myhead>
      <van-row>
        <van-col span="3"> <navigation></navigation>  </van-col>
        <van-col span="21"> 
            <br>
             职务名称：<input type="text" v-model="text"> <van-button @click="like">查询</van-button>  <van-button @click="fun">重置</van-button>  <br>
             <br>
             <van-button>新增</van-button>  <van-button @click="download">导出</van-button>  
                  <van-uploader :after-read="uploader">
                    <van-uploader>
                        <van-button icon="plus" type="primary">导入文件</van-button>
                    </van-uploader>
                    </van-uploader>
             <br> <br>
            <table width="800px">
                <tr>
                    <td>序号</td>
                    <td>职务名称</td>
                    <td>职务编码</td>
                    <td>操作</td>
                    
                </tr>
                <tr v-for="(i,index) in datas" :key="i.id">   
                    <td> {{index + 1}} </td>  
                  <td> {{i.name}} </td>
                  <td> {{i.code}} </td>
                  <td>
                      <van-button @click="updupyst(i.id)">编辑</van-button>
                      <van-button @click="deldupyst(i.id)">删除</van-button>
                  </td>
                </tr>
                
            </table>
            
            
        </van-col>
        
      </van-row>
      
  </div>
</template>

<script>
import Myhead from '../comm/myhead.vue'
import navigation from '../comm/left.vue'
import axios from 'axios'




export default {
    data(){
      return{
        datas:[],
        text:''
       
       
      }
    },
    components:{
        Myhead,
        navigation,

    },
    methods:{
        getdutys(){
            axios.get('/getdutys').then(res=>{
                console.log(res);
                this.datas = res.data.data
            })
        },
        like(){
            axios.get('/getdutys?test='+this.text).then(res=>{
                console.log(res);
                this.datas = res.data.data
            })
        },


      uploader(file) {
        let formData = new FormData()
        formData.append('file', file.file)
        axios({method: 'post',url: '/upload', data: formData}).then(res => {
                console.log(res)
        })
    },
      download(){
        axios({mounted:'post',url:'download'}).then(res=>{
          console.log(res);
        })
      },
     updupyst(id){
         axios.post('/getdutys',{'name':'部门主管','code':'023','id':id}).then(res=>{
                console.log(res);
            })
     },
     delpost(){

     },
     fun(){
         
         this.getdutys()
     }
      

    },
    mounted(){
        this.getdutys()
    }
    
}
</script>

<style>

</style>


